home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / oop_tp55.zip / LIST5_2A.PAS < prev    next >
Pascal/Delphi Source File  |  1980-01-07  |  2KB  |  69 lines

  1. program Listing5_2A;
  2.  
  3. type
  4.  
  5. Elf = object
  6.       Name : string;
  7.       constructor Init( Monicker : string );
  8.       procedure ShopScript;  virtual;
  9.       procedure GoShopping;
  10.       end;
  11.  
  12. VirtualElf = object( Elf )
  13.            procedure ShopScript; virtual;
  14.            end;
  15.  
  16. constructor Elf.Init( Monicker : string );
  17. begin
  18.      Name := Monicker;
  19. end;
  20.  
  21. procedure Elf.ShopScript;
  22. begin
  23.      writeln( '<Door slams as ', Name, ' leaves>');
  24.      writeln( '<long pause.......>' );
  25.      writeln( '<Door slams as ', Name, ' returns>');
  26.      writeln( Name,
  27.          ': I went to the store and bought milk and eggs.');
  28. end;
  29.  
  30. procedure Elf.GoShopping;
  31. begin
  32.      ShopScript;
  33. end;
  34.  
  35. procedure VirtualElf.ShopScript;
  36. var
  37.    ShoppingList : string;
  38. begin
  39.      writeln( Name,
  40.             ': When I get to the store, I''ll call you.');
  41.      writeln( '<Door slams as ', Name, ' leaves>');
  42.      writeln( '<pause.......>' );
  43.      writeln( 'PHONE: Brrring!');
  44.      writeln( '<pick up phone>' );
  45.      writeln( 'YOU: Hello?' );
  46.      writeln( Name, ': Hi. What do you want me to buy?' );
  47.      write( 'YOU (enter something): ');
  48.      readln( ShoppingList );
  49.      writeln( Name, ': Gotcha. Bye.');
  50.      writeln( '<hang up phone>' );
  51.      writeln( '<pause.......>' );
  52.      writeln( '<Door slams as ', Name, ' returns>');
  53.      writeln( Name, ': As you requested, I bought: ',
  54.                                           ShoppingList );
  55. end;
  56.  
  57. var
  58.    Jay : Elf;
  59.    Ray : VirtualElf;
  60.  
  61. begin
  62.      Jay.Init( 'JAY' );
  63.      Ray.Init( 'RAY' );
  64.  
  65.      Jay.GoShopping;
  66.      Ray.GoShopping;
  67. end.
  68.  
  69. { end of Listing 5-2A }